﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _0912276_ChatClient
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HyperLink hl = (HyperLink)Master.FindControl("HLSearchMember");
            hl.CssClass = "activebox";
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            String id = txtMembershipID.Text;
            string firstname = txtFirstName.Text;
            string lastname = txtLastName.Text;
            List<employee> lstMember =new List<employee>();
            if (!string.IsNullOrEmpty(id))
                lstMember = BO.SearchMember.FindMemberWithid(int.Parse(id));
            else
            {
                if ((!string.IsNullOrEmpty(firstname)) && (!string.IsNullOrEmpty(lastname)))
                {
                    lstMember = BO.SearchMember.FindMemberWithFirstNameAndLastName(firstname, lastname);
                }
                else
                {
                    if (!string.IsNullOrEmpty(firstname))
                        lstMember = BO.SearchMember.FindMemberWithFirstName(firstname);
                    else
                        if (!string.IsNullOrEmpty(lastname))
                            lstMember = BO.SearchMember.FindMemberWithLastName(lastname);
                }
            }
            if (lstMember.Count > 0)
            {
                dlNguoiDung.DataSource = lstMember;
                dlNguoiDung.DataBind();
                Panel1.Visible = false;
            }
            else
            {
                Panel1.Visible = true;
                dlNguoiDung.DataSource = null;
                dlNguoiDung.DataBind();
            }
        }
    }
}